package org.study.hadoop.md.util;

import java.util.HashMap;
import java.util.Map;
/**
 * 简单解析StackOverFlow工具类
 *
 */
public class MRDPUtils {
	
	public static final String[] REDIS_INSTANCES = { "p0", "p1", "p2", "p3",
			"p4", "p6" };

	// This helper function parses the stackoverflow into a Map for us.
	public static Map<String, String> transformXmlToMap(String xml) {
		Map<String, String> map = new HashMap<String, String>();
		try {
			String[] tokens = xml.trim().substring(5, xml.trim().length() - 3)
					.split("\"");
			String[] tokens2 = tokens[0].split("\t");

			for (int i = 0; i < tokens2.length; i ++) {
				String key = tokens2[i].trim().split("=")[0];
				String val = tokens2[i].trim().split("=")[1];

				map.put(key, val);
			}
		} catch (StringIndexOutOfBoundsException e) {
			System.err.println(xml);
		}

		return map;
	}
}
